<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author XPF
-->
<template>
  <BasicDrawer
    v-bind="$attrs"
    :showFooter="true"
    :okAuth="'sports:sportsTemplateConfig:edit'"
    @register="tempregiser"
    width="60%"
  >
    <p>{{ grade }}体侧模板</p>
    <p>{{ schoolName }}</p>
    <BasicTable @register="infoTable" />
    <BasicTable @register="shapeTable" />
    <BasicTable @register="PhysicalTable" />
    <BasicTable @register="qualityTable" />
  </BasicDrawer>
</template>
<script lang="ts">
export default defineComponent({
  name: 'ViewsSportsSportsTemplateConfigForm',
});
</script>
<script lang="ts" setup>
import { defineComponent, ref, computed } from 'vue';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMessage } from '/@/hooks/web/useMessage';
import { router } from '/@/router';
import { Icon } from '/@/components/Icon';
import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import {
  SportsTemplateConfig,
  sportsTemplateConfigListData,
} from '/@/api/sports/sportsTemplateConfig';
const emit = defineEmits(['success', 'register']);

const { t } = useI18n('sports.sportsTemplateConfig');
const { showMessage } = useMessage();
const record = ref<SportsTemplateConfig>({} as SportsTemplateConfig);
let grade = '';
let schoolName = '';
const infoColumns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'name',
    width: 150,
  },
  {
    title: '测评时间',
    dataIndex: 'createDate',
    width: 150,
  },
  {
    title: '年级',
    dataIndex: 'adaptGrade',
    width: 150,
  },
  {
    title: '年龄',
    dataIndex: 'age',
    width: 150,
  },
  {
    title: '性别',
    dataIndex: 'sex',
    width: 150,
  },
];

const shapeColumns: BasicColumn[] = [
  {
    title: '项目',
    dataIndex: 'indexName',
    width: 150,
  },
  {
    title: '成绩',
    dataIndex: 'score',
    width: 150,
  },
];

const PhysicalColumns: BasicColumn[] = [
  {
    title: '项目',
    dataIndex: 'indexName',
    width: 150,
  },
  {
    title: '成绩',
    dataIndex: 'score',
    width: 150,
  },
  {
    title: '权重',
    dataIndex: 'weight',
    width: 150,
  },
  {
    title: '测试状态',
    dataIndex: 'testStatusDisplay',
    width: 150,
  },
];

const qualityColumns: BasicColumn[] = [
  {
    title: '项目',
    dataIndex: 'indexName',
    width: 150,
  },
  {
    title: '成绩',
    dataIndex: 'score',
    width: 150,
  },
  {
    title: '权重',
    dataIndex: 'weight',
    width: 150,
  },
  {
    title: '测试状态',
    dataIndex: 'testStatusDisplay',
    width: 150,
  },
];
const infoSource = [{ id: '1', name: '/', createDate: '/', adaptGrade: '/', age: '/', sex: '/' }];
let shapeSource =<any>[];
let PhysicalSource = <any>[];
let qualitySource = <any>[];
const [tempregiser, { closeDrawer }] = useDrawerInner((data)=> {
  shapeSource = []
  PhysicalSource = []
  qualitySource = []
  grade = data.adaptGrade;
  data.sportsIndexTemplateRelationList.forEach((item, index) => {
    switch (item.indexType) {
      case '1':
        shapeSource.push({ id: index + 1, indexName: item.indexName, score: '/' });
        break;
      case '2':
        PhysicalSource.push({
          id: index + 1,
          indexName: item.indexName,
          score: '/',
          weight: item.weight,
          testStatusDisplay: item.testStatusDisplay ? '测试' : '无法测试',
        });
        break;
      case '3':
        qualitySource.push({
          id: index + 1,
          indexName: item.indexName,
          score: '/',
          weight: item.weight,
          testStatusDisplay: item.testStatusDisplay ? '测试' : '无法测试',
        });
        break;
    }
  });
  shapeTableData(shapeSource),
  physicalTableData(PhysicalSource),
  qualityTableData(qualitySource),
    reload();
    shapeReload();
    PhysicalReload();
    qualityReload();
});

const [infoTable, { reload }] = useTable({
  pagination: false,
  columns: infoColumns,
  showTableSetting: false,
  dataSource: infoSource,
  title:'基础信息'
});
const [shapeTable, { reload: shapeReload,setTableData:shapeTableData }] = useTable({
  pagination: false,
  columns: shapeColumns,
  showTableSetting: false,
  // dataSource: shapeSource,
  title:'身体形态'

  // canResize:true,
});

const [PhysicalTable, { reload: PhysicalReload,setTableData:physicalTableData }] = useTable({
  pagination: false,
  columns: PhysicalColumns,
  showTableSetting: false,
  // dataSource: PhysicalSource,
  title:'身体机能'

});
const [qualityTable, { reload: qualityReload,setTableData:qualityTableData }] = useTable({
  pagination: false,
  columns: qualityColumns,
  showTableSetting: false,
  // dataSource: qualitySource,
  title:'身体素质'
  // canResize:true,
});
</script>
